import React from 'react'
import { Table } from 'antd'
import PropTypes from 'prop-types'
import './manager.less'
import RightsViewer from './RightViewer'

class IcsComponentsIdleGrid extends React.Component {
    state = {
        showViewer: false,
        rowInfo: {},
        isEditing: false
    }
    componentDidMount () {
    }
    editRights = (row) => {
        console.log(row)
        this.setState({showViewer: true, rowInfo: row, isEditing: true})
    }
    doViewer = () => {
        this.setState({showViewer: false})
    }
    render () {
        return (
            <div className="manager-grid">
                <Table
                    pagination={false}
                    bordered
                    dataSource={this.props.list}
                    rowKey="id">
                    <Table.Column
                        title="权限码"
                        width={120}
                        dataIndex="pri_code"
                    />
                    <Table.Column
                        title="权限名称"
                        dataIndex="pri_name"
                        width={150}
                    />
                    <Table.Column
                        title="权限说明"
                        width={120}
                        dataIndex="pri_note"
                    />
                    <Table.Column
                        title="操作"
                        width={150}
                        render={(text, row) => {
                            return <div><a onClick={(() => this.editRights(row))}>编辑</a></div>
                        }}
                    />
                </Table>
                <RightsViewer doViewer={this.doViewer} showViewer={this.state.showViewer} doSearch={this.props.doSearch} isEditing={this.state.isEditing} rowInfo={this.state.rowInfo}></RightsViewer>
            </div>
        )
    }
}

IcsComponentsIdleGrid.propTypes = {
    onCreate: PropTypes.func,
    onIdleDetail: PropTypes.func,
    doSearch: PropTypes.func,
    list: PropTypes.array,
    grid: PropTypes.any
}
export default IcsComponentsIdleGrid
